package compare.comparator;

import java.util.Map;
import java.util.TreeMap;

public class demo {
    public static void main1(String[] args) {
        ComparatorId comparatorId = new ComparatorId();
        ComparatorName comparatorName = new ComparatorName();
        Student student1 = new Student(1,"A");
        Student student2 = new Student(2,"A");

        System.out.println(comparatorId.compare(student1, student2));
        System.out.println(comparatorName.compare(student1,student2));

    }
    public static void main(String[] args) {
        Student student1 = new Student(1,"A");
        Student student2 = new Student(2,"B");
        //ComparatorId
        Map<Student,Integer> map1 = new TreeMap<>(new ComparatorId());
        map1.put(student1,1);
        map1.put(student2,5);
        for(Map.Entry<Student,Integer> entry : map1.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
        System.out.println("-------------------------------------------------");
        //ComparatorName
        Map<Student,Integer> map2 = new TreeMap<>(new ComparatorName());
        map2.put(student1,1);
        map2.put(student2,5);
        for(Map.Entry<Student,Integer> entry : map2.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
        System.out.println("-------------------------------------------------");
    }
}
